package com.yq.testmodule.adapter;

import android.graphics.Color;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.yq.testmodule.R;

import java.util.List;

public class SimpleAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
    public SimpleAdapter(@Nullable List<String> data) {
        super(R.layout.item_simple_2, data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, String s) {
        int itemPosition = getItemPosition(s);
        if(itemPosition%2==1){
            baseViewHolder.setBackgroundColor(R.id.tvItem, Color.GREEN);
        }
        baseViewHolder.setText(R.id.tvItem,s);
    }
}
